package com.fau.wm.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 仓库信息表
 * @author liy
 * @datetime 2014年7月26日,下午5:33:51
 */
@Entity
@Table(name = "medical_warehouse")
public class MedicalWarehouse implements Serializable ,JSONAware{

	private static final long serialVersionUID = 8836998176558722148L;

	private String id;
	
	@NotBlank(message = "仓库名称不能为空！")
	@Length(max = 85, message = "仓库名称长度需要在0和85之间")
	private String name;		// 名称
	
	@NotBlank(message = "地址不能为空！")
	@Length(max = 85, message = "地址长度需要在0和85之间")
	private String address;		// 地址
	
	@NotBlank(message = "面积大小不能为空！")
	@Length(max = 20, message = "面积大小长度需要在0和20之间")
	private String area;		// 面积大小
	
	private String code;		// 编号
	private String hospitalId;	//医院标识id
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name", length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "address", length = 255)
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "area", length = 20)
	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	@Column(name = "code", length = 30)
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("name", name);
		obj.put("address", address);
		obj.put("area", area);
		obj.put("code", code);
		return obj.toString();
	}
	
}
